home *** CD-ROM | disk | FTP | other *** search
/ Champak 62 / Volume 62 - JOGO DISK .iso / interface / browser.swf / scripts / FUIComponentSymbol.as < prev   
Text File  |  2008-05-28  |  9KB  |  325 lines

  1. function FUIComponentClass()
  2. {
  3.    this.init();
  4. }
  5. FUIComponentClass.prototype = new MovieClip();
  6. FUIComponentClass.prototype.init = function()
  7. {
  8.    this.enable = true;
  9.    this.focused = false;
  10.    this.useHandCursor = false;
  11.    this._accImpl = new Object();
  12.    this._accImpl.stub = true;
  13.    this.styleTable = new Array();
  14.    if(_global.globalStyleFormat == undefined)
  15.    {
  16.       _global.globalStyleFormat = new FStyleFormat();
  17.       globalStyleFormat.isGlobal = true;
  18.       _global._focusControl = new Object();
  19.       _global._focusControl.onSetFocus = function(oldFocus, newFocus)
  20.       {
  21.          oldFocus.myOnKillFocus();
  22.          newFocus.myOnSetFocus();
  23.       };
  24.       Selection.addListener(_global._focusControl);
  25.    }
  26.    if(this._name != undefined)
  27.    {
  28.       this._focusrect = false;
  29.       this.tabEnabled = true;
  30.       this.focusEnabled = true;
  31.       this.tabChildren = false;
  32.       this.tabFocused = true;
  33.       if(this.hostStyle == undefined)
  34.       {
  35.          globalStyleFormat.addListener(this);
  36.       }
  37.       else
  38.       {
  39.          this.styleTable = this.hostStyle;
  40.       }
  41.       this.deadPreview._visible = false;
  42.       this.deadPreview._width = this.deadPreview._height = 1;
  43.       this.methodTable = new Object();
  44.       this.keyListener = new Object();
  45.       this.keyListener.controller = this;
  46.       this.keyListener.onKeyDown = function()
  47.       {
  48.          this.controller.myOnKeyDown();
  49.       };
  50.       this.keyListener.onKeyUp = function()
  51.       {
  52.          this.controller.myOnKeyUp();
  53.       };
  54.       for(var _loc3_ in this.styleFormat_prm)
  55.       {
  56.          this.setStyleProperty(_loc3_,this.styleFormat_prm[_loc3_]);
  57.       }
  58.    }
  59. };
  60. FUIComponentClass.prototype.setEnabled = function(enabledFlag)
  61. {
  62.    this.enable = arguments.length <= 0 ? true : enabledFlag;
  63.    this.tabEnabled = this.focusEnabled = enabledFlag;
  64.    if(!this.enable && this.focused)
  65.    {
  66.       Selection.setFocus(undefined);
  67.    }
  68. };
  69. FUIComponentClass.prototype.getEnabled = function()
  70. {
  71.    return this.enable;
  72. };
  73. FUIComponentClass.prototype.setSize = function(w, h)
  74. {
  75.    this.width = w;
  76.    this.height = h;
  77.    this.focusRect.removeMovieClip();
  78. };
  79. FUIComponentClass.prototype.setChangeHandler = function(chng, obj)
  80. {
  81.    this.handlerObj = obj != undefined ? obj : this._parent;
  82.    this.changeHandler = chng;
  83. };
  84. FUIComponentClass.prototype.invalidate = function(methodName)
  85. {
  86.    this.methodTable[methodName] = true;
  87.    this.onEnterFrame = this.cleanUI;
  88. };
  89. FUIComponentClass.prototype.cleanUI = function()
  90. {
  91.    if(this.methodTable.setSize)
  92.    {
  93.       this.setSize(this.width,this.height);
  94.    }
  95.    else
  96.    {
  97.       this.cleanUINotSize();
  98.    }
  99.    this.methodTable = new Object();
  100.    delete this.onEnterFrame;
  101. };
  102. FUIComponentClass.prototype.cleanUINotSize = function()
  103. {
  104.    for(var _loc2_ in this.methodTable)
  105.    {
  106.       this._loc2_();
  107.    }
  108. };
  109. FUIComponentClass.prototype.drawRect = function(x, y, w, h)
  110. {
  111.    var _loc4_ = this.styleTable.focusRectInner.value;
  112.    var _loc5_ = this.styleTable.focusRectOuter.value;
  113.    if(_loc4_ == undefined)
  114.    {
  115.       _loc4_ = 16777215;
  116.    }
  117.    if(_loc5_ == undefined)
  118.    {
  119.       _loc5_ = 0;
  120.    }
  121.    this.createEmptyMovieClip("focusRect",1000);
  122.    this.focusRect.controller = this;
  123.    this.focusRect.lineStyle(1,_loc5_);
  124.    this.focusRect.moveTo(x,y);
  125.    this.focusRect.lineTo(x + w,y);
  126.    this.focusRect.lineTo(x + w,y + h);
  127.    this.focusRect.lineTo(x,y + h);
  128.    this.focusRect.lineTo(x,y);
  129.    this.focusRect.lineStyle(1,_loc4_);
  130.    this.focusRect.moveTo(x + 1,y + 1);
  131.    this.focusRect.lineTo(x + w - 1,y + 1);
  132.    this.focusRect.lineTo(x + w - 1,y + h - 1);
  133.    this.focusRect.lineTo(x + 1,y + h - 1);
  134.    this.focusRect.lineTo(x + 1,y + 1);
  135. };
  136. FUIComponentClass.prototype.pressFocus = function()
  137. {
  138.    this.tabFocused = false;
  139.    this.focusRect.removeMovieClip();
  140.    Selection.setFocus(this);
  141. };
  142. FUIComponentClass.prototype.drawFocusRect = function()
  143. {
  144.    this.drawRect(-2,-2,this.width + 4,this.height + 4);
  145. };
  146. FUIComponentClass.prototype.myOnSetFocus = function()
  147. {
  148.    this.focused = true;
  149.    Key.addListener(this.keyListener);
  150.    if(this.tabFocused)
  151.    {
  152.       this.drawFocusRect();
  153.    }
  154. };
  155. FUIComponentClass.prototype.myOnKillFocus = function()
  156. {
  157.    this.tabFocused = true;
  158.    this.focused = false;
  159.    this.focusRect.removeMovieClip();
  160.    Key.removeListener(this.keyListener);
  161. };
  162. FUIComponentClass.prototype.executeCallBack = function()
  163. {
  164.    this.handlerObj[this.changeHandler](this);
  165. };
  166. FUIComponentClass.prototype.updateStyleProperty = function(styleFormat, propName)
  167. {
  168.    this.setStyleProperty(propName,styleFormat[propName],styleFormat.isGlobal);
  169. };
  170. FUIComponentClass.prototype.setStyleProperty = function(propName, value, isGlobal)
  171. {
  172.    if(value == "")
  173.    {
  174.       return undefined;
  175.    }
  176.    var _loc17_ = parseInt(value);
  177.    if(!isNaN(_loc17_))
  178.    {
  179.       value = _loc17_;
  180.    }
  181.    var _loc16_ = arguments.length <= 2 ? false : isGlobal;
  182.    if(this.styleTable[propName] == undefined)
  183.    {
  184.       this.styleTable[propName] = new Object();
  185.       this.styleTable[propName].useGlobal = true;
  186.    }
  187.    if(this.styleTable[propName].useGlobal || !_loc16_)
  188.    {
  189.       this.styleTable[propName].value = value;
  190.       if(!this.setCustomStyleProperty(propName,value))
  191.       {
  192.          if(propName == "embedFonts")
  193.          {
  194.             this.invalidate("setSize");
  195.          }
  196.          else if(propName.subString(0,4) == "text")
  197.          {
  198.             if(this.textStyle == undefined)
  199.             {
  200.                this.textStyle = new TextFormat();
  201.             }
  202.             var _loc18_ = propName.subString(4,propName.length);
  203.             this.textStyle[_loc18_] = value;
  204.             this.invalidate("setSize");
  205.          }
  206.          else
  207.          {
  208.             for(var _loc15_ in this.styleTable[propName].coloredMCs)
  209.             {
  210.                var _loc4_ = new Color(this.styleTable[propName].coloredMCs[_loc15_]);
  211.                if(this.styleTable[propName].value == undefined)
  212.                {
  213.                   var _loc5_ = {ra:"100",rb:"0",ga:"100",gb:"0",ba:"100",bb:"0",aa:"100",ab:"0"};
  214.                   _loc4_.setTransform(_loc5_);
  215.                }
  216.                else
  217.                {
  218.                   _loc4_.setRGB(value);
  219.                }
  220.             }
  221.          }
  222.       }
  223.       this.styleTable[propName].useGlobal = _loc16_;
  224.    }
  225. };
  226. FUIComponentClass.prototype.registerSkinElement = function(skinMCRef, propName)
  227. {
  228.    if(this.styleTable[propName] == undefined)
  229.    {
  230.       this.styleTable[propName] = new Object();
  231.       this.styleTable[propName].useGlobal = true;
  232.    }
  233.    if(this.styleTable[propName].coloredMCs == undefined)
  234.    {
  235.       this.styleTable[propName].coloredMCs = new Object();
  236.    }
  237.    this.styleTable[propName].coloredMCs[skinMCRef] = skinMCRef;
  238.    if(this.styleTable[propName].value != undefined)
  239.    {
  240.       var _loc4_ = new Color(skinMCRef);
  241.       _loc4_.setRGB(this.styleTable[propName].value);
  242.    }
  243. };
  244. _global.FStyleFormat = function()
  245. {
  246.    this.nonStyles = {listeners:true,isGlobal:true,isAStyle:true,addListener:true,removeListener:true,nonStyles:true,applyChanges:true};
  247.    this.listeners = new Object();
  248.    this.isGlobal = false;
  249.    if(arguments.length > 0)
  250.    {
  251.       for(var _loc3_ in arguments[0])
  252.       {
  253.          this[_loc3_] = arguments[0][_loc3_];
  254.       }
  255.    }
  256. };
  257. _global.FStyleFormat.prototype = new Object();
  258. FStyleFormat.prototype.addListener = function()
  259. {
  260.    var _loc3_ = 0;
  261.    while(_loc3_ < arguments.length)
  262.    {
  263.       var _loc4_ = arguments[_loc3_];
  264.       this.listeners[arguments[_loc3_]] = _loc4_;
  265.       for(var _loc5_ in this)
  266.       {
  267.          if(this.isAStyle(_loc5_))
  268.          {
  269.             _loc4_.updateStyleProperty(this,_loc5_.toString());
  270.          }
  271.       }
  272.       _loc3_ = _loc3_ + 1;
  273.    }
  274. };
  275. FStyleFormat.prototype.removeListener = function(component)
  276. {
  277.    this.listeners[component] = undefined;
  278.    for(var _loc4_ in this)
  279.    {
  280.       if(this.isAStyle(_loc4_))
  281.       {
  282.          if(component.styleTable[_loc4_].useGlobal == this.isGlobal)
  283.          {
  284.             component.styleTable[_loc4_].useGlobal = true;
  285.             var _loc3_ = !this.isGlobal ? globalStyleFormat[_loc4_] : undefined;
  286.             component.setStyleProperty(_loc4_,_loc3_,true);
  287.          }
  288.       }
  289.    }
  290. };
  291. FStyleFormat.prototype.applyChanges = function()
  292. {
  293.    var _loc6_ = 0;
  294.    for(var _loc5_ in this.listeners)
  295.    {
  296.       var _loc3_ = this.listeners[_loc5_];
  297.       if(arguments.length > 0)
  298.       {
  299.          var _loc4_ = 0;
  300.          while(_loc4_ < arguments.length)
  301.          {
  302.             if(this.isAStyle(arguments[_loc4_]))
  303.             {
  304.                _loc3_.updateStyleProperty(this,arguments[_loc4_]);
  305.             }
  306.             _loc4_ = _loc4_ + 1;
  307.          }
  308.       }
  309.       else
  310.       {
  311.          for(_loc4_ in this)
  312.          {
  313.             if(this.isAStyle(_loc4_))
  314.             {
  315.                _loc3_.updateStyleProperty(this,_loc4_.toString());
  316.             }
  317.          }
  318.       }
  319.    }
  320. };
  321. FStyleFormat.prototype.isAStyle = function(name)
  322. {
  323.    return !this.nonStyles[name] ? true : false;
  324. };
  325.